Skip to content

Remove id guid id roundtrips - #5318

Open
svkrieger wants to merge 7 commits into
mainfrom
remove-id-guid-id-roundtrips
Open

Remove id guid id roundtrips#5318
svkrieger wants to merge 7 commits into
mainfrom
remove-id-guid-id-roundtrips

Conversation

@svkrieger

@svkrieger svkrieger commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

A short explanation of the proposed change:

Follow-up to #5157 and #5172.
Remove all guid -> id -> guid roundtrips mechanically.

An explanation of the use cases your change solves

Improves performance in the following API paths:
app/fetchers/org_list_fetcher.rb - GET /v3/organizations
app/fetchers/organization_quota_list_fetcher.rb - GET /v3/organization_quotas
app/fetchers/service_plan_visibility_fetcher.rb - marketplace visibility checks
app/fetchers/security_group_list_fetcher.rb / security_group_fetcher.rb - GET /v3/security_groups*
app/fetchers/isolation_segment_organizations_fetcher.rb - GET /v3/isolation_segments/:guid/organizations
app/fetchers/domain_fetcher.rb - GET /v3/domains*
app/presenters/v3/organization_quota_presenter.rb, domain_presenter.rb, domain_shared_orgs_presenter.rb

Before / After perf test results — id → guid → id round-trip removal (medians, N=3)

Endpoint / case Before After Δ
organizations — admin 178.7ms 178.3ms ~0
organizations — regular 189.1ms 168.1ms −11%
organizations — regular, page 500 254.6ms 250.7ms −2%
org_quotas — admin 1201.6ms 1348.5ms +12% (noise, σ=183ms)
org_quotas — regular 952.1ms 539.9ms −43%
org_quotas — regular, page 500 962.3ms 570.2ms −41%
iso_segments — list admin 222.2ms 230.4ms +4% (noise)
iso_segments — list regular 229.9ms 254.0ms +10% (noise)
iso_segments — list admin, page 500 777.8ms 838.3ms +8% (noise)
iso_segments — rel/orgs admin 147.6ms 147.3ms ~0
iso_segments — rel/orgs regular 157.5ms 157.7ms ~0

Analysis

Wins — non-admin permission filtering:

  • org_quotas regular −43%, page 500 −41%. Presenter filters orgs once per quota (50 quotas × ~2000 orgs). Round-trip removal compounds.
  • organizations regular −11%. σ=0.6ms, real.

Neutral (expected):

  • Admin cases flat. Hit can_read_globally? short-circuit — not touched.
  • iso_segments rel/orgs flat. ~20 orgs per segment; segment join runs first, permission filter sees tiny set. Round-trip cost negligible at this scale.

Noise, not regressions:

  • org_quotas admin +12%: σ jumped to 183ms, unchanged code path.
  • iso_segments list +4–10%: endpoint doesn't call the changed fetcher.

Bottom line: Large win on non-admin org_quotas (~40%), solid on organizations regular (−11%). Admin + unrelated paths unchanged.

Links to any other associated PRs

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Add readable_org_ids_for_domains_query and readable_security_group_ids_query,
mirroring the existing *_guids_query helpers but returning the flat id UNION
without the enclosing SELECT ... FROM organizations/security_groups WHERE id IN
wrapper. Prerequisite for removing id -> guid -> id round-trips from V3
read-permission filters.

Follow-up to #5157 and #5172.
Switch OrgListFetcher and the organization presenter args to the bare-id
readable_org_ids_query, collapsing the id -> guid -> id round-trip on the
non-admin GET /v3/organizations path into a single WHERE id IN (UNION).

Follow-up to #5157 and #5172.
Switch OrganizationQuotaListFetcher and OrganizationQuotaPresenter to the
bare-id readable_org_ids_query. The presenter's per-quota visible-org filter
previously ran an id -> guid -> id round-trip once per quota returned; it now
filters directly on organizations.id.

Follow-up to #5157 and #5172.
Switch DomainFetcher, DomainPresenter, DomainSharedOrgsPresenter and the
domains/default-domain paths on OrganizationsController to the bare-id
readable_org_ids(_for_domains)_query, removing the id -> guid -> id round-trip
from domain read-permission filtering.

Follow-up to #5157 and #5172.
Switch ServicePlanVisibilityFetcher to the bare-id readable_org_ids_query,
removing the id -> guid -> id round-trip from marketplace visibility checks.

Follow-up to #5157 and #5172.
Switch SecurityGroupListFetcher and SecurityGroupFetcher to the new bare-id
readable_security_group_ids_query, removing the id -> guid -> id round-trip
from the security group visibility filter. The single-resource guid lookup and
the guid-membership checks on individual actions are left untouched.

Follow-up to #5157 and #5172.
Switch IsolationSegmentOrganizationsFetcher (backing
GET /v3/isolation_segments/:guid/relationships/organizations for non-admins)
to the bare-id readable_org_ids_query. The IsolationSegmentListFetcher path is
left as-is: its organizations association is keyed on guid through the join
table, so no org id is in scope there.

Follow-up to #5157 and #5172.
@svkrieger
svkrieger force-pushed the remove-id-guid-id-roundtrips branch from 3301d77 to 687013f Compare July 30, 2026 10:12
@svkrieger
svkrieger marked this pull request as ready for review July 31, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant